﻿using Api.Ordering.Tool;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Api.Ordering.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class UserLoginController : ControllerBase
    {
        [HttpPost]
        public Result Login([FromBody] User user)
        {
            if (user.UserName == "admin" && user.Password == "123456")
            {
                return new Result("ok");
            }
            else
            {

                return new Result("用户名密码不正确");
            }

        }


        [HttpGet("getlist")]
        public Result GetList()
        {
            var users = new List<Person>();
            users.Add(new Person() { Id = 1, Name = "张啥", Age = 18 });
            users.Add(new Person() { Id = 2, Name = "张啥2", Age = 18 });
            users.Add(new Person() { Id = 3, Name = "张啥3", Age = 18 });
            users.Add(new Person() { Id = 4, Name = "张啥4", Age = 18 });

            users.Add(new Person() { Id = 5, Name = "张啥5", Age = 18 });
            users.Add(new Person() { Id = 6, Name = "张啥6", Age = 18 });

            users.Add(new Person() { Id = 7, Name = "张啥7", Age = 18 });
            users.Add(new Person() { Id = 8, Name = "张啥8", Age = 18 });
            users.Add(new Person() { Id = 9, Name = "张啥9", Age = 18 });
            users.Add(new Person() { Id = 10, Name = "张啥10", Age = 18 });

            users.Add(new Person() { Id = 11, Name = "张啥11", Age = 18 });
            users.Add(new Person() { Id = 12, Name = "张啥12", Age = 18 });
            users.Add(new Person() { Id = 13, Name = "张啥13", Age = 18 });
            users.Add(new Person() { Id = 14, Name = "张啥14", Age = 18 });


            return new Result(users);

        }

        [HttpGet("info")]
        public Result GetInfo()
        {
            Person person = new Person();

            person.Age = 20;
            person.Id = 1;
            person.Name = "admin";

            MenuController menuController = new MenuController();
            //person.Menus = menuController.GetList();


            return new Result(new { Data=person ,Menus = menuController.GetList() });
        }


    }



    public class User
    {

        public string UserName { get; set; }

        public string Password { get; set; }
    }


    public class Person
    {
        public int Id { get; set; }

        public string Name { get; set; }

        public int Age { get; set; }

        //private List<Menu> menus = new List<Menu>();

        //public List<Menu> Menus { get => menus; set => menus= value; }


    }

}
